import { judicialInvolvementApi } from "../../api/shesu"
Page({
  /**
   * 页面的初始数据
   */
  data: {
    page: 1,
    perPage: 10,
    debtorId: "",
    companyId: "",
    total: 0,
    loading: false,
    contentList: [],
  },
  // 上拉到底
  scrolltolower() {
    if (this.data.total > this.data.contentList.length) {
      this.data.page++;
      this.getList();
    }
  },
  // 下拉刷新
  refresherrefresh() {
    this.searchHandle();
  },
  searchHandle() {
    this.data.page = 1;
    this.setData({
      contentList: []
    })
    this.getList();
  },
  // 查看详情
  viewDetail(e: any) {
    let row = e.currentTarget.dataset.row;
    // console.log(row, "row")
    wx.navigateTo({
      url: "/subPackages/packageA/shesu/bankruptDetail/bankruptDetail?row=" + JSON.stringify(row)
    })
  },
  // 获取涉诉信息列表
  getList() {
    this.setData({
      loading: true
    })
    let para = {
      page: this.data.page,
      perPage: this.data.perPage,
      companyId: this.data.companyId
    }

    judicialInvolvementApi(para).then((res: any) => {
      let contentList = res.content.list;
      this.data.total = res.content.total;
      this.setData({
        loading: false,
        contentList: this.data.contentList.concat(contentList),
        total: res.content.total
      })
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(option) {
    console.log(option, "option")
    this.data.debtorId = option.debtorId;
    this.data.companyId = option.companyId;
    this.getList();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },


})